import { FC } from "react";
import "./index.scss";

import { Modal, Progress } from "antd";

interface AutoUpdateProps {
  isModalOpen: boolean;
  percent: number;
  onDownload: () => void;
  onCancel: () => void;
}

export const AutoUpdate: FC<AutoUpdateProps> = ({
  isModalOpen,
  percent,
  onDownload,
  onCancel
}): JSX.Element => {
  const handleOk = () => {
    onDownload();
  };
  const handleCancel = () => {
    onCancel();
  };

  return (
    <div>
      <Modal
        title="下载升级包"
        okText="下载并安装"
        cancelText="关闭"
        open={isModalOpen}
        onOk={handleOk}
        onCancel={handleCancel}
      >
        <Progress percent={percent} />
      </Modal>
    </div>
  );
};
